layui.define(['jquery'],function(exports){
  //do something
  var $ = layui.jquery;

  var type = {
    POST:'post',
    GET:'get',
    DELETE:'delete',
    PUT:'put',
    PATCH:'patch'
  };
  var fun = function () {};
  // ajax封装
  function ajax(url, param, success, error, type) {
    $.ajax({
      type: type,
      url: url,
      headers : {
        'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'
      },
      data: param,
      dataType: 'json',
      success: success,
      error: error
    });
  }
  var http = {
    get:function(url,param,success,error){
      ajax(url,param,success || fun,error || fun,type.GET)
    },
    post:function(url,param,success,error){
      ajax(url,param,success || fun,error || fun,type.POST)
    },
    put:function(url,param,success,error){
      ajax(url,param,success || fun,error || fun,type.PUT)
    },
    patch:function(url,param,success,error){
      ajax(url,param,success || fun,error || fun,type.PATCH)
    }
  };


  var httpRouter = new (function () {
    //this.ApiUrl = 'http://172.16.0.179/ins/index.php';
    this.ApiUrl = 'http://124.207.148.51/ins/index.php';
    //this.ApiUrl = 'http://172.0.0.1/ins/index.php';
    //登录
    this.login = this.ApiUrl + '?r=cncs&ac=login/login';

    //首页
    //基础信息
    this.baseinfo = this.ApiUrl + '?r=base&ac=base/info';

    //首页菜单
    this.basemenu = this.ApiUrl + '?r=base&ac=base/menu';


    // 营养筛查
    //科室列表
    this.cnisdeplistinfo = this.ApiUrl + '?r=base&ac=base/deplistinfo';

    //床号列表
    this.bednolistinfo = this.ApiUrl + '?r=base&ac=base/bednolistinfo';

    //患者姓名列表
    this.userinfo = this.ApiUrl + '?r=base&ac=base/userinfo';

    //复核人列表
    this.reviewuserinfo = this.ApiUrl + '?r=base&ac=base/reviewuserinfo';

    //临床医生列表
    this.clinicianinfo = this.ApiUrl + '?r=base&ac=base/clinicianinfo';

    //筛查明细列表
    this.searchmanage = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/searchmanage';

    //打印结果
    this.printresult = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/printresult';

    //复核
    this.checkrisk = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/check';

    //营养会诊
    this.consultationofdoctors = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/consultationofdoctors';

    //关注患者
    this.payattention = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/payattention';


    //营养看板
    //科室列表
    this.basedeplistinfo = this.ApiUrl + '?r=base&ac=base/deplistinfo';

    //今日变化状态人数
    this.getchangecount = this.ApiUrl + '?r=base&ac=base/getchangecount';

    //病人总数详情
    this.patientstotalinfo = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/patientstotalinfo';

    //护理营养看板列表明细
    this.viewmanage = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/viewmanage';


    // 统计查询
    // 营养风险统计
    // 昨天入院患者营养风险统计
    this.yesterdayinrisk = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/yesterdayinrisk';

    // 在院患者营养风险统计
    this.nowrisk = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/nowrisk';

    // 昨天入院患者营养风险统
    this.yesriskpatient = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/yesriskpatient';

    // 营养干预占比和营养治疗人
    this.intervenechange = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/intervenechange';

    // 复核中作量统计
    // 营养干预占比和营养治疗
    this.reviewchange = this.ApiUrl + '?r=riskscreeningmanage&ac=riskscreeningmanage/reviewchange';

  });


  exports('httpService', http);
  exports('httpRouter',httpRouter);
});
